home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / UTILITIE / CONVERSI / 3760.ZIP / APL2EM.ZIP / MEMORY.ASM < prev    next >
Assembly Source File  |  1990-03-30  |  7KB  |  236 lines

  1.     Page    58,132
  2.     Title    MEMORY.ASM    Memory Access Routines
  3. ;******************************************************************************
  4. ;
  5. ;   Name:    MEMORY.ASM    Memory Access Routines
  6. ;
  7. ;   Group:    Emulator
  8. ;
  9. ;   Revision:    1.00
  10. ;
  11. ;   Date:    January 30, 1988
  12. ;
  13. ;   Author:    Randy W. Spurlock
  14. ;
  15. ;******************************************************************************
  16. ;
  17. ;  Module Functional Description:
  18. ;
  19. ;        This module contains all the code for the standard
  20. ;    type memory accesses.
  21. ;
  22. ;******************************************************************************
  23. ;
  24. ;  Changes:
  25. ;
  26. ;    DATE     REVISION                DESCRIPTION
  27. ;  --------   --------    -------------------------------------------------------
  28. ;   1/30/88    1.00    Original
  29. ;
  30. ;******************************************************************************
  31.     Page
  32. ;
  33. ;  Public Declarations
  34. ;
  35.     Public    Memory_Init        ; Memory initialization routine
  36.     Public    STD_Mem_Read        ; Standard memory read routine
  37.     Public    STD_Mem_Write        ; Standard memory write routine
  38.     Public    ROM_Mem_Read        ; ROM memory read routine
  39.     Public    ROM_Mem_Write        ; ROM memory write routine
  40.     Public    Special_Read        ; Special none selected read routine
  41.     Public    Special_Write        ; Special none selected write routine
  42. ;
  43. ;  LOCAL Equates
  44. ;
  45. MEMORY_SIZE    Equ    8000h        ; 65C02 RAM memory size (Words)
  46. ;
  47. ;  Define any include files needed
  48. ;
  49.     Include     Macros.inc    ; Include the macro definitions
  50.     Include     Equates.inc    ; Include the equate definitions
  51.     .286c                ; Include 80286 instructions
  52.     Page
  53. ;
  54. ;  Define the emulator code segment
  55. ;
  56. Emulate Segment Word Public 'EMULATE'   ; Emulator code segment
  57.     Assume    cs:Emulate, ds:Nothing, es:Nothing
  58.     Subttl    Memory_Init    Memory Initialization
  59.     Page    +
  60. ;******************************************************************************
  61. ;
  62. ;    Memory_Init(RAM_Space)
  63. ;
  64. ;        Save the required registers
  65. ;        Zero all memory locations
  66. ;        Restore the required registers
  67. ;        Return to the caller
  68. ;
  69. ;    Registers on Entry:
  70. ;
  71. ;        DS    - RAM space
  72. ;
  73. ;    Registers on Exit:
  74. ;
  75. ;        None
  76. ;
  77. ;******************************************************************************
  78.         Even            ; Force procedure to even address
  79. Memory_Init    Proc    Near        ; Memory initialization procedure
  80.     Save    ax,cx,di,es        ; Save the required registers
  81.     mov    ax,ds            ; Get the RAM space segment value
  82.     mov    es,ax            ; Setup ES to the RAM segment
  83.     xor    ax,ax            ; Setup to zero the memory locations
  84.     mov    cx,MEMORY_SIZE        ; Setup to zero all of memory
  85.     xor    di,di            ; Setup pointer to start of memory
  86.     rep    stosw            ; Store all zeros to the memory
  87.     Restore ax,cx,di,es        ; Restore the required registers
  88.     ret                ; Return to the caller
  89. Memory_Init    Endp            ; End of the Memory_Init procedure
  90.     Subttl    STD_Mem_Read    Standard Memory Read
  91.     Page    +
  92. ;******************************************************************************
  93. ;
  94. ;    STD_Mem_Read(Effective_Address)
  95. ;
  96. ;        Read the memory location value (Byte)
  97. ;        Return to the caller
  98. ;
  99. ;    Registers on Entry:
  100. ;
  101. ;        DS:DI - 65C02 Effective address
  102. ;
  103. ;    Registers on Exit:
  104. ;
  105. ;        AL    - Memory value
  106. ;
  107. ;******************************************************************************
  108.         Even            ; Force procedure to even address
  109. STD_Mem_Read    Proc    Near        ; Standard memory read procedure
  110.     mov    al,ds:[di]        ; Read the memory location
  111.     ret                ; Return to the caller
  112. STD_Mem_Read    Endp            ; End of the STD_Mem_Read procedure
  113.     Subttl    STD_Mem_Write    Standard Memory Write
  114.     Page    +
  115. ;******************************************************************************
  116. ;
  117. ;    STD_Mem_Write(Effective_Address, Value)
  118. ;
  119. ;        Write value to memory location value (Byte)
  120. ;        Return to the caller
  121. ;
  122. ;    Registers on Entry:
  123. ;
  124. ;        AL    - Memory value
  125. ;        DS:DI - 65C02 Effective address
  126. ;
  127. ;    Registers on Exit:
  128. ;
  129. ;        None (Memory location updated)
  130. ;
  131. ;******************************************************************************
  132.         Even            ; Force procedure to even address
  133. STD_Mem_Write    Proc    Near        ; Standard memory write procedure
  134.     mov    ds:[di],al        ; Write the memory location
  135.     ret                ; Return to the caller
  136. STD_Mem_Write    Endp            ; End of the STD_Mem_Write procedure
  137.     Subttl    ROM_Mem_Read    ROM Memory Read
  138.     Page    +
  139. ;******************************************************************************
  140. ;
  141. ;    ROM_Mem_Read(Effective_Address)
  142. ;
  143. ;        Read the memory location value (Byte)
  144. ;        Return to the caller
  145. ;
  146. ;    Registers on Entry:
  147. ;
  148. ;        DS:DI - 65C02 Effective address
  149. ;
  150. ;    Registers on Exit:
  151. ;
  152. ;        AL    - Memory value
  153. ;
  154. ;******************************************************************************
  155.         Even            ; Force procedure to even address
  156. ROM_Mem_Read    Proc    Near        ; ROM memory read procedure
  157.     mov    al,ds:[di]        ; Read the memory location
  158.     ret                ; Return to the caller
  159. ROM_Mem_Read    Endp            ; End of the ROM_Mem_Read procedure
  160.     Subttl    ROM_Mem_Write    ROM Memory Write
  161.     Page    +
  162. ;******************************************************************************
  163. ;
  164. ;    ROM_Mem_Write(Effective_Address, Value)
  165. ;
  166. ;        Return to the caller
  167. ;
  168. ;    Registers on Entry:
  169. ;
  170. ;        AL    - Memory value
  171. ;        DS:DI - 65C02 Effective address
  172. ;
  173. ;    Registers on Exit:
  174. ;
  175. ;        None
  176. ;
  177. ;******************************************************************************
  178.         Even            ; Force procedure to even address
  179. ROM_Mem_Write    Proc    Near        ; ROM memory write procedure
  180.     ret                ; Return to the caller
  181. ROM_Mem_Write    Endp            ; End of the ROM_Mem_Write procedure
  182.     Subttl    Special_Read    Special None Selected Read
  183.     Page    +
  184. ;******************************************************************************
  185. ;
  186. ;    Special_Read(Effective_Address)
  187. ;
  188. ;        Read the memory location value (Byte)
  189. ;        Return to the caller
  190. ;
  191. ;    Registers on Entry:
  192. ;
  193. ;        DS:DI - 65C02 Effective address
  194. ;
  195. ;    Registers on Exit:
  196. ;
  197. ;        AL    - Memory value
  198. ;
  199. ;******************************************************************************
  200.         Even            ; Force procedure to even address
  201. Special_Read    Proc    Near        ; Special none selected read procedure
  202.     mov    al,ds:[di]        ; Read the memory location
  203.     ret                ; Return to the caller
  204. Special_Read    Endp            ; End of the Special_Read procedure
  205.     Subttl    Special_Write    Special None Selected Write
  206.     Page    +
  207. ;******************************************************************************
  208. ;
  209. ;    Special_Write(Effective_Address, Value)
  210. ;
  211. ;        Write value to memory location value (Byte)
  212. ;        Return to the caller
  213. ;
  214. ;    Registers on Entry:
  215. ;
  216. ;        AL    - Memory value
  217. ;        DS:DI - 65C02 Effective address
  218. ;
  219. ;    Registers on Exit:
  220. ;
  221. ;        None (Memory location updated)
  222. ;
  223. ;******************************************************************************
  224.         Even            ; Force procedure to even address
  225. Special_Write    Proc    Near        ; Special none selected write procedure
  226.     mov    ds:[di],al        ; Write the memory location
  227.     ret                ; Return to the caller
  228. Special_Write    Endp            ; End of the Special_Write procedure
  229. ;******************************************************************************
  230. ;
  231. ;    Define the end of the Emulator Code Segment
  232. ;
  233. ;******************************************************************************
  234. Emulate Ends
  235.     End                ; End of the Memory module
  236.